﻿using System;
using System.Collections.Generic;
using NakedObjects;
using System.ComponentModel;

namespace HRMDomain
{
    public class Base
    {

        public IDomainObjectContainer Container { set; protected get; }


        [Hidden]
        public virtual int Id { get; set; }
        [Disabled]
        public virtual DateTime CreatedOn { get; set; }
        private Nullable<DateTime> _LastModifiedOn;
        [Disabled]
        public virtual Nullable<DateTime> LastModifiedOn 
        { 
            get
            {
                return _LastModifiedOn;
            } 
            set
            {
                _LastModifiedOn = value;
            } 
        }
        [Disabled]
        public virtual string CreatedBy { get; set; }
        private string _LastModifiedBy;
        [Disabled]
        public virtual string LastModifiedBy {
            get
            {
                return _LastModifiedBy;
            }
            set
            {
                _LastModifiedBy = value;
            }
        }

        public void Created()
        {
            CreatedOn = DateTime.Now;
            _LastModifiedOn = null;
            CreatedBy = Container.Principal.Identity.Name;
        }

        public void Updating()
        {
            _LastModifiedOn = DateTime.Now;
            CreatedBy = Container.Principal.Identity.Name;
        }
    }
}
